<template>
	<!-- 首页 -->
	<view :class="model+'-wrap'">
		<!-- :class="'p-sticky-'+model" -->
		<view>
			<view :class="model+'-wrap2'">
				<view :class="'p-sticky-'+model">
					<view :class="model+'-wrap2'">
						<view class="status_bar">

						</view>
						<!-- 顶部tabbar -->
						<view class="mx-3 flex align-center justify-between">
							<view class="f0">
								<image @click="$tool.navTo('/pages/mine/mine')" style="width: 48rpx;height: 48rpx;"
									:src="'/static/images/index/2_'+model+'.png'" mode="">
								</image>
							</view>
							<view class="topBar flex" :class="model=='light'?'topBarLight':''">
								<view @click="changeTopBarIndex(0)" :class="topBarIndex==0?'item2':'item'"
									class="A-Medium flex-1 flex align-center justify-center">
									{{i18n.i001}}
								</view>
								<view @click="changeTopBarIndex(1)" :class="topBarIndex==1?'item2':'item'"
									class="A-Medium flex-1 flex align-center justify-center">
									{{i18n.i002}}
								</view>
								<view @click="changeTopBarIndex(2)" :class="topBarIndex==2?'item2':'item'"
									class="A-Medium flex-1 flex align-center justify-center">
									{{i18n.i003}}
								</view>
							</view>
							<view class="f0">
								<image @click="clickService" style="width: 48rpx;height: 48rpx;"
									:src="'/static/images/index/3_'+model+'.png'" mode="">
								</image>
							</view>
						</view>
					</view>
				</view>
				<!-- 公告 -->
				<view class="notice" @click="$tool.navTo('/pages/index/myMessage')"
					:class="model=='light'?'noticeLight':''">
					<uni-notice-bar :fontSize="13" scrollable="true" :iconSrc="'/static/images/index/4_'+model+'.png'"
						showIcon="true" :color="model=='dark'?'#AAACB8':'rgba(255,255,255,0.7)'"
						:text="noticeText" /></uni-section>
				</view>
				<view class="flex align-center mt-5">
					<view class="flex-1">
						
					</view>
					<!-- 资产、收益 -->
					<view @click="clickBtn(-1)" class="flex scrollH align-center justify-center">
						<view class="moneyType A-Medium">
							{{i18n.i004}}（{{moneyType}}）
						</view>
						<view class="f0">
							<image style="width: 18rpx;height: 12rpx;" :src="'/static/images/downArrow_'+model+'.png'"
								mode="">
							</image>
						</view>
					</view>
					<view class="flex-1 flex justify-end">
						<!-- :style="'top:'+scrollH+'px;'" -->
						<view @click="$tool.navTo('/pages/member/member')"  class="vipIcon flex align-center justify-center">
							<view class="f0">
								<image style="width: 28rpx;height: 28rpx;margin-right: 6rpx;"
									:src="'/static/images/mine/4_'+model+'.png'" mode=""></image>
							</view>
							<view class="" style="font-weight: 700;font-size: 24rpx;color: #FFB41F;">
								{{vipClass}}
							</view>
						</view>
					</view>
				</view>
				<view class="money D-Bold text-alignC" :class="model=='light'?'moneyLight':''">
					{{
						moneyType=='USDT'?USDTMoney.z == 0 ? "0.00" : USDTMoney.z :
						moneyType=='BTC'?BTCMoney.z == 0 ? "0.00" : BTCMoney.z :
						moneyType=='ETH'?ETHMoney.z == 0 ? "0.00" : ETHMoney.z :''
					}}
				</view>
				<view class="money2 A-Medium text-alignC">
					{{i18n.i005}}
					<text :class="(
								moneyType=='USDT' ? USDTMoney.s:
								moneyType=='BTC' ? BTCMoney.s:
								moneyType=='ETH' ? ETHMoney.s:''
					) < 0 ? 'text2' : 'text'" style="margin-right: 10rpx;">
						{{
							getFormattedAmount(
								moneyType=='USDT' ? USDTMoney.s:
								moneyType=='BTC' ? BTCMoney.s:
								moneyType=='ETH' ? ETHMoney.s:''
							)
						}}
					</text>
					<!-- <text :class="USDTMoney.s<0?'text2':'text'">
						{{
							moneyType=='USDT'?USDTMoney.b:
							moneyType=='BTC'?BTCMoney.b:
							moneyType=='ETH'?ETHMoney.b:''
						}}%
					</text> -->
				</view>
				<view class="mx-5 A-Medium mt-3 flex align-center justify-between">
					<!-- clickBtn(1) -->
					<view @click="$tool.navTo('/pages/property/chongzhi?type=1')" class="flex btn align-center justify-center"
						:class="model=='light'?'btnLight':''">
						<view class="f0 mr-1">
							<!-- <image style="width: 36rpx;height: 36rpx;" :src="'/static/images/index/5_'+model+'.png'"
								mode="">
							</image> -->
							<image style="width: 36rpx;height: 36rpx;" :src="'/static/images/property/4_'+model+'.png'" mode="">
							</image>
						</view>
						<view class="money2" :class="model=='light'?'money2Light':''"
							style="font-size: 26rpx;margin-top: 0;">
							{{i18n.i006}}
						</view>
					</view>
					<!-- clickBtn(2) -->
					<view @click="$tool.navTo('/pages/property/huazhuan?type=1')" class="flex btn align-center justify-center"
						:class="model=='light'?'btnLight':''">
						<view class="f0 mr-1">
							<!-- <image style="width: 36rpx;height: 36rpx;" :src="'/static/images/index/6_'+model+'.png'"
								mode="">
							</image> -->
							<image style="width: 36rpx;height: 36rpx;" :src="'/static/images/property/6_'+model+'.png'" mode="">
							</image>
						</view>
						<view class="money2" :class="model=='light'?'money2Light':''"
							style="font-size: 26rpx;margin-top: 0;">
							<!-- {{i18n.i007}} -->
							{{i18n10.n143}}
						</view>
					</view>
					<!-- clickBtn(3) -->
					<view @click="$tool.navTo('/pages/property/tixian?type=1')" class="flex btn align-center justify-center"
						:class="model=='light'?'btnLight':''">
						<view class="f0 mr-1">
							<!-- <image style="width: 36rpx;height: 36rpx;" :src="'/static/images/index/7_'+model+'.png'"
								mode="">
							</image> -->
							<image style="width: 36rpx;height: 36rpx;" :src="'/static/images/property/5_'+model+'.png'" mode="">
							</image>
						</view>
						<view class="money2" :class="model=='light'?'money2Light':''"
							style="font-size: 26rpx;margin-top: 0;">
							{{i18n.i008}}
						</view>
					</view>
				</view>
				<!-- 轮播图 -->
				<view class="m-3">
					<!-- <image @click="$tool.navTo('/pages/invitationRewards/invitationRewards')"
						style="width: 690rpx;height: 186rpx;" 
						mode="aspectFill">
					</image> -->
					<swiper style="height: 186rpx;" :indicator-color="'#7F838D'" :indicator-active-color="'#F7F7F7'"
						:indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
						<!-- $tool.navTo('/pages/invitationRewards/invitationRewards') -->
						<swiper-item v-for="(item,index) in swiperList" @click="clickSwiper(item)">
							<!-- <image style="width: 690rpx;height: 186rpx;" :src="'/static/images/banner_'+'dark'+'.png'" mode="aspectFill">
							</image> -->
							<image style="width: 690rpx;height: 186rpx;" :src="$tool.changeImg(item.pictureUrl)" mode="aspectFill">
							</image>
						</swiper-item>
					</swiper>
				</view>
				<!-- 最新报价 -->
				<view class="newPrice flex align-center" :class="model=='light'?'newPriceLight':''">
					<view @click="goPage('USDT')" :class="priceType==0?'item1':'item1'"
						class="flex-1 flex flex-column align-center justify-center">
						<view class="title A-Medium flex align-center justify-center">
							<view class="f0">
								<image style="width: 28rpx;height: 28rpx;margin-right: 4rpx;"
									src="/static/images/index/21.png" mode=""></image>
							</view>
							USDT
						</view>
						<view class="desc A-Regular">
							{{i18n2.t003}}
						</view>
					</view>
					<view @click="goPage('BTC')" :class="priceType==0?'item1':'item1'"
						class="flex-1 flex flex-column align-center justify-center">
						<view class="title A-Medium flex align-center justify-center">
							<view class="f0">
								<image style="width: 28rpx;height: 28rpx;margin-right: 4rpx;"
									src="/static/images/index/8.png" mode=""></image>
							</view>
							BTC
						</view>
						<view class="desc A-Regular">
							{{i18n2.t003}}
						</view>
					</view>
					<view @click="goPage('ETH')" :class="priceType==1?'item1':'item1'"
						class="flex-1 flex flex-column align-center justify-center">
						<view class="title A-Medium flex align-center justify-center">
							<view class="f0">
								<image style="width: 28rpx;height: 28rpx;margin-right: 4rpx;"
									src="/static/images/index/11.png" mode=""></image>
							</view>
							ETH
						</view>
						<view class="desc A-Regular">
							{{i18n2.t003}}
						</view>
					</view>

				</view>
			</view>
		</view>

		<!-- 活动 -->
		<view class="guess A-Medium mx-3 mb-3 p-3" :class="model=='light'?'guessLight':''">
			<view class="mb-2 flex align-center">
				<view class="f0">
					<image style="width: 161rpx;height: 37rpx;" :src="'/static/images/index/15_'+model+'.png'" mode="">
					</image>
				</view>
				<view class="guessTitle">
					赢取1个btc大奖励
				</view>
			</view>
			<view class="flex align-center">
				<view class="flex align-center flex-1">
					<view class="f0">
						<image style="width: 40rpx;height: 40rpx;" :src="'/static/images/index/16_'+model+'.png'"
							mode=""></image>
					</view>
					<view class="guessTitle2">
						{{i18n.i018}}：
					</view>
					<view v-if="btcPrice"
						:class="(btcPrice.priceChangePercent24h.indexOf('-')!=-1)?'valueItem2':'valueItem3'"
						class="mx-1 A-Regular">
						${{(btcPrice.price/1).toFixed(2)}}
					</view>
					<view v-if="btcPrice"
						:class="(btcPrice.priceChangePercent24h.indexOf('-')!=-1)?'valueItem2':'valueItem3'"
						class="mx-1 A-Regular">
						{{(btcPrice.priceChangePercent24h/1).toFixed(2)}}%
					</view>
				</view>
				<view @click="$tool.navTo('/pages/index/guessingCompetition')" class="flex align-center">
					<view class="guessTitle2">
						{{i18n.i019}}
					</view>
					<view class="f0">
						<image style="width: 28rpx;height: 28rpx;" :src="'/static/images/index/20_'+model+'.png'"
							mode=""></image>
					</view>
				</view>
			</view>
			<view v-if="isCanguess" class="flex align-center">
				<view class="f0">
					<image style="width: 40rpx;height: 40rpx;" :src="'/static/images/index/17_'+model+'.png'" mode="">
					</image>
				</view>
				<view class="guessTitle2 flex align-center">
					{{guessingStart ? (guessingEnd ? i18n.i022 : i18n.i020) : i18n.i044}}：
					<view class="times A-Medium">
						{{hours}}
					</view>
					<view class="times A-Medium mx-1">
						{{minutes}}
					</view>
					<view class="times A-Medium">
						{{seconds}}
					</view>
				</view>
			</view>
			<view class="mt-3 mb-1 flex align-center">
				<view class="A-Regular" :class="{ 'valueItem2': guessingStart, 'valueItem1Light' : !guessingStart}" style="font-size: 24rpx;">
					{{guessingStart ? rate : '0%'}}
				</view>
				<view class="mx-2 flex-1 flex align-center justify-end"
					style="background: #53D290;border-radius: 100rpx;height: 20rpx;overflow: hidden;flex-shrink: 0;">
					<view v-if="guessingStart" class="" style="position: relative;background: #D22540;height: 20rpx;border-radius: 0 10rpx 10rpx 0;"
						:style="'width:'+rate2">
						<image v-if="rate != '0%' && rate2 != '100%'" style="height: 40rpx;position: absolute;top: 0rpx;left: -5rpx;transform: scaleX(-1);" src="/static/images/pross.png"
							mode="heightFix"></image>
					</view>
					<view v-if="!guessingStart || (rate == '0%' && rate2 == '0%')" class="" style="background: #f1f1f1;height: 20rpx;border-radius: 0 10rpx 10rpx 0;"
						:style="'width: 100%'">
							
					</view>
				</view>
				<view class="A-Regular" :class="{ 'valueItem3': guessingStart, 'valueItem1Light' : !guessingStart}" style="font-size: 24rpx;">
					{{guessingStart ? rate2 : '0%' }}
				</view>
			</view>
			<template v-if="!isCanguess">
				<view class="flex guessTitle2 align-center justify-center"
					style="margin-top: 22rpx;margin-bottom: 6rpx;">
					{{i18n.i021}}：<view class="valueItem3" style="font-size: 40rpx;">
						{{guessResult=='Bullish'?i18n.i039:i18n.i040}}
					</view>
				</view>
				<view class="flex align-center justify-center">
					<view class="guessTitle2 flex align-center">
						{{i18n.i022}}
						<view class="times A-Medium">
							{{hours}}
						</view>
						<view class="times A-Medium mx-1">
							{{minutes}}
						</view>
						<view class="times A-Medium">
							{{seconds}}
						</view>
					</view>
				</view>
			</template>
			<view class="guessTitle2 text-alignC" style="font-size: 20rpx;margin-top: 16rpx;margin-bottom: 24rpx;">
				{{i18n.i023}}
			</view>
			<view v-if="isCanguess&&guessingStart" class="flex align-center justify-center">
				<view @click="getActivityDetailAdd(1)" class="mr-3 flex align-center justify-center kanz"
					:class="model=='light'?'kanzLight':''">
					<view class="">
						{{i18n.i024}}
					</view>
					<view class="f0">
						<image style="width: 20rpx;height: 20rpx;" :src="'/static/images/index/18_'+model+'.png'"
							mode="">
						</image>
					</view>
				</view>
				<view @click="getActivityDetailAdd(2)" class="kand flex align-center justify-center"
					:class="model=='light'?'kandLight':''">
					<view class="">
						{{i18n.i025}}
					</view>
					<view class="f0">
						<image style="width: 20rpx;height: 20rpx;" :src="'/static/images/index/19_'+model+'.png'"
							mode="">
						</image>
					</view>
				</view>
			</view>
		</view>
		<!-- 最新资讯 -->
		<view class="news A-Regular mb-2 p-3 mx-3" :class="model=='light'?'newsLight':''">
			<view class="newsTitle A-Medium">
				{{i18n.i026}}
			</view>
			<view v-for="(item,index) in newList" :key="index"
				@click="$tool.navTo('/pages/index/articleDetail?id='+item.id)" class="mt-3">
				<view class="name text-overflow1">
					{{item.title}}
				</view>
				<view class="time">
					<!-- 2024/5/18 18:58 -->
					{{item.createTime}}
				</view>
			</view>
			<view @click="moreNewsList" class="seeMore mt-3 flex align-center justify-center">
				{{i18n.i027}}
				<view class="f0">
					<image style="width: 28rpx;height: 28rpx;margin-left: 8rpx;"
						:src="'/static/images/index/20_'+model+'.png'" mode=""></image>
				</view>
			</view>
		</view>
		<czPoup ref="czPoups" :type="btnType" @confirm="czConfirm"></czPoup>
		
	</view>
</template>

<script>
	import {
		newsList,
		getCoinNetworkList,
		noticeList,
		activityDetailAdd,
		activityDetailQueryRate,
		activityDetailQueryResult,
		activityRuleBTC_USDT_PRICE,
		carouselList,
		getActivityTime
	} from '@/core/api/index.js';
	import CryptoJS from 'crypto-js';
	import czPoup from '@/components/czPoup.vue';
	import websocket from '@/core/libs/websocket.js';
	var websocketObj;
	export default {
		components: {
			czPoup
		},
		data() {
			return {
				topBarIndex: 1,
				moneyType: 'USDT',
				priceType: 0,
				isCanguess: true,
				guessResult: '',
				rate: '0%',
				rate2: '0%',
				hours: '00',
				minutes: '00',
				seconds: '00',
				timer2: null,
				// 最新资讯
				pageNo: 1,
				pageSize: 3,
				newList: [],
				btnType: 1, //1充值 2转账 3提现
				noticeText: '',
				// btcPrice: '',
				scrollH:0,
				swiperList:[],
				isSubmit:false,
				guessingStart: false,
				guessingEnd: false,
				qiyuModule: null
			}
		},
		
		computed: {
			i18n() {
				return this.$t('index')
			},
			i18n2() {
				return this.$t('trade')
			},
			i18n4() {
				return this.$t('last3')
			},
			i18n10() {
				return this.$t('newObj')
			},
			model() {
				return this.$store.state.config.model
			},
			BTCList() {
				return this.$store.state.config.BTCList
			},
			ETHList() {
				return this.$store.state.config.ETHList
			},
			USDTMoney() {
				return this.$store.state.config.USDTMoney
			},
			BTCMoney() {
				return this.$store.state.config.BTCMoney
			},
			ETHMoney() {
				return this.$store.state.config.ETHMoney
			},
			passportAuthStatus() {
				return this.$store.state.config.passportAuthStatus
			},
			vipClass() {
				return this.$store.state.config.vipClass;
			},
			btcPrice() {
				return this.$store.state.config.btcPrice;
			},
		},
		onTabItemTap(e){
			this.$tool.setStatusBarStyle(this.model);
		},
		onLoad() {
			carouselList({
				pageNo: 1,
				pageSize: 1000
			}).then(res=>{
				// console.log(res,'cs---banner');
				this.swiperList = res.result.records.filter((e) => e.type == "1");
			})
			if (!uni.getStorageSync('mobileUserId')) {
				return;
			}
			this.$tool.showLoading();
			// /websocket/{userId}
			// wss://uexsocket.vvv5g.com:20001 
			// websocketObj = new websocket('ws://szsc.laobailianmeng.com/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://shuzisc.laobailianmeng.com/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			websocketObj = new websocket('ws://shuzisc.luckycat.website/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://192.168.111.108:9623/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://154.91.176.220:8080/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://154.91.176.220:8888/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://srwq22.natappfree.cc/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://192.168.8.117:9623/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			// websocketObj = new websocket('ws://192.168.1.198:9623/digital-mall/websocket/'+uni.getStorageSync('mobileUserId')+'_'+CryptoJS.MD5(uni.getStorageSync('token')).toString(),this.getNewMessage);
			this.$store.commit("config/set_isContinue", true);
			this.$store.commit("config/set_isContinue2", true);
			// 当前BTC指数价
			// activityRuleBTC_USDT_PRICE({}).then(res => {
			// 	this.btcPrice = res.result;
			// })

			this.getNewsList();
			this.getNoticeList();
			this.getActivityDetailQueryResult();
			getActivityTime().then(res=>{
				console.log(res,'cs---------getRemainingTimeToday');
				let list = res.result;
				let start_time;
				let end_time;
				for(let i=0;i<list.length;i++){
					if(list[i].value=='end_time'){
						end_time = list[i].text;
					}
					if(list[i].value=='start_time'){
						start_time = list[i].text;
					}
				}
				this.timer2 = setInterval(res => {
					this.getRemainingTimeToday(start_time,end_time);
				}, 1000)
			})
			// if (this.BTCList.length == 0 || this.ETHList.length == 0) {
			// 	this.$tool.showLoading();
			// 	this.$store.dispatch('config/getExchangeListBTC');
			// 	this.$store.dispatch('config/getExchangeListETH');
			// }
			this.$store.dispatch('config/getCustomerInfo');
			// 用户余额
			this.$store.dispatch('config/getAassetList');
			// 期权
			this.$store.dispatch('config/getNewOptionsProfitLoss');
			this.$store.dispatch('config/getNewOptionsOpenCondition');
			
		},
		onReady() {
			this.$tool.setStatusBarStyle(this.model);
			this.getScrollHeight('scrollH').then(res => {
				console.log(res,'cs------------------------cs');
				this.scrollH = res-3;
			})
		},
		onShow() {
			this.setTabbar();
			this.$tool.setStatusBarStyle(this.model);
			// 用户余额
			this.$store.dispatch('config/getAassetList');
			this.getActivityDetailQueryRate();

			const pages = getCurrentPages();
			const page = pages[pages.length - 1];
			const currentWebview = page.$getAppWebview();
			if(this.model == "dark"){
				currentWebview.setStyle({
					background: "#0E0F11"
				});
			}else{
				currentWebview.setStyle({
					background: "#ffffff"
				});
			}
			
			this.$refs.czPoups.closePopup();
		},
		onUnload() {
		    if (this.timer) {
		      clearTimeout(this.timer);
		      this.timer = null;
		    }
		  },
		onHide() {
			if (this.timer) {
			  clearTimeout(this.timer);
			  this.timer = null;
			}
		},
		onPullDownRefresh() {
			// 用户余额
			this.$store.dispatch('config/getAassetList');
			this.getActivityDetailQueryRate();
		},
		methods: {
			clickSwiper(item){
				if(item.netUrl){
					if(item.netUrl.indexOf("http://") == 0 || item.netUrl.indexOf("https://") == 0){
						plus.runtime.openURL(item.netUrl);
					} else if(item.netUrl.indexOf("/pages") == 0){
						this.$tool.navTo(item.netUrl)
					}
				}
			},
			getScrollHeight(elementClass) {
				return new Promise((resolve, reject) => {
					let scroll_content_height = 0;
					uni.getSystemInfo({
						success: (res) => {
							let win_height = res.windowHeight;
							const scroll_node = uni.createSelectorQuery().select(
								`.${elementClass}`);
							scroll_node
								.boundingClientRect((result) => {
									scroll_content_height = win_height - result.top;
									// console.log(scroll_content_height,"新的高度");
									resolve(result.top)
								})
								.exec();
						}
					})
				})
			},
			getNewMessage(obj){
				this.$store.commit("config/changeNewMessage",obj);
			},
			goPage(e) {
				uni.setStorageSync('lType', e);
				this.$tool.navTo('/pages/trade/trade2')
			},
			clickService() {
				this.$qiyuModule.openServiceActivity({
					title: '在线客服',
					// source: {
					// 	title: 'qiyu',
					// 	//如果需要发送商品卡片，设置商品卡片信息
					// 	productDetail: {
					// 		title: "商品卡片",
					// 		picture: "https://img",
					// 		desc: "我是商品卡片的描述",
					// 		url: "www.xxx.com",
					// 	}
					// },
				})
			},
			changeTopBarIndex(e) {
				if (e != 2) {
					this.$tool.navTo('/pages/trade/trade?topBarIndex=' + e, 4);
					uni.$emit('changeTopBarIndex', e);
				} else {
					this.$tool.navTo('/pages/option/option', 4);
				}
				if (this.topBarIndex == e) {
					return;
				}
				this.topBarIndex = e;
			},
			changePriceType(e) {
				if (e == 2) {
					this.$tool.navTo('/pages/trade/trade?topBarIndex=' + e, 4);
					uni.$emit('changeTopBarIndex', e);
				}
				if (this.priceType == e) {
					return;
				}
				this.priceType = e;
			},
			getNewsList() {
				let timeOut = 1000
				setTimeout(() => {
					newsList({
						pageNo: this.pageNo,
						pageSize: this.pageSize
					}).then(res => {
						let list = res.result.records;
						if (this.pageNo == 1) {
							this.newList = list;
						} else {
							if (list.length == 0) {
								this.pageNo--;
								this.$tool.showToast(this.i18n4.l006);
							} else {
								this.newList.push(...list);
							}
						}
						timeOut = 5000
						this.getNewsList()
					})
				}, timeOut)
			},
			moreNewsList() {
				this.pageSize = this.pageSize * 2;
				newsList({
					pageNo: this.pageNo,
					pageSize: this.pageSize
				}).then(res => {
					let list = res.result.records;
					if (list.length == this.newList.length) {
						this.$tool.showToast(this.i18n4.l006);
						this.pageSize = this.pageSize / 2;
					} else {
						this.newList = list;
					}
				})
			},
			clickBtn(e) {
				this.btnType = e;
				this.$refs.czPoups.open();
				// if(e==1){
				// 	// 充值
				// 	this.$tool.navTo('/pages/property/chongzhi');
				// } else if(e==2){
				// 	// 转账
				// 	this.$tool.navTo('/pages/property/huazhuan')
				// } else if(e==3){
				// 	// 提现
				// 	this.$tool.navTo('/pages/property/tixian')
				// }
			},
			// 充值弹窗
			czConfirm(item) {
				console.log(item,'cs');
				if (this.btnType == 1) {
					// 充值
					uni.setStorageSync('czType', item.value);
					this.$tool.navTo('/pages/property/chongzhi?type=' + item.id);
				} else if (this.btnType == 2) {
					// 转账
					uni.setStorageSync('hzType', item.value);
					this.$tool.navTo('/pages/property/huazhuan?type=' + item.id)
				} else if (this.btnType == 3) {
					// 提现
					uni.setStorageSync('txType', item.value);
					this.$tool.navTo('/pages/property/tixian?type=' + item.id)
				} else if (this.btnType == -1) {
					// 切换
					this.moneyType = item.value;
				}
			},
			getNoticeList() {
				let that = this
				setTimeout(() => {
					noticeList().then(res => {
						let list = res.result.records;
						that.noticeText = list[0].content;
						that.getNoticeList()
					})
				}, 8000) 
			},
			// 查看你猜结果
			getActivityDetailQueryResult() {
				activityDetailQueryResult({
					mobileUserId: uni.getStorageSync('mobileUserId'),
				}).then(res => {
					this.guessResult = res.result.guessResult;
					if (this.guessResult) {
						this.isCanguess = false;
					}
					this.isSubmit = false;
				}).catch(err=>{
					this.isSubmit = false;
				})
			},
			// 看涨或看跌比例
			getActivityDetailQueryRate() {
				activityDetailQueryRate({}).then(res => {
					uni.stopPullDownRefresh();
					let list = res.result;
					for (let i = 0; i < list.length; i++) {
						if (list[i].guessResult == 'Bullish') {
							this.rate2 = list[i].rate;
						} else {
							this.rate = list[i].rate;
						}
					}
				}).catch(res=>{
					uni.stopPullDownRefresh();
				})
			},
			// 参与活动
			getActivityDetailAdd(e) {
				if(this.isSubmit){
					return;
				}else{
					this.isSubmit = true;
				}
				activityDetailAdd({
					guessResult: e == 1 ? 'Bullish' : 'Bearish',
					mobileUserId: uni.getStorageSync('mobileUserId')
				}).then(res => {
					console.log(res, 'cs-getActivityDetailAdd');
					this.getActivityDetailQueryResult();
					this.getActivityDetailQueryRate();
				}).catch(err=>{
					this.isSubmit = false;
				})
			},
			getRemainingTimeToday(start_time, end_time) {
				let now = new Date();
				let startOfDay = this.getDateByTime(now, start_time);
				let endOfDay = this.getDateByTime(now, end_time);
				let remainingMilliseconds;
				let remainingSeconds;
				let remainingMinutes;
				let remainingHours;
				if(startOfDay - now > 0){
					//未开始
					remainingMilliseconds = startOfDay-now;
					remainingSeconds = Math.floor(remainingMilliseconds / 1000);
					remainingMinutes = Math.floor(remainingSeconds / 60);
					remainingHours = Math.floor(remainingMinutes / 60);
					remainingSeconds %= 60;
					remainingMinutes %= 60;
					remainingHours %= 24;
					remainingHours<0?remainingHours=0:'';
					remainingMinutes<0?remainingMinutes=0:'';
					remainingSeconds<0?remainingSeconds=0:'';
					this.hours = remainingHours > 9 ? remainingHours : '0' + remainingHours;
					this.minutes = remainingMinutes > 9 ? remainingMinutes : '0' + remainingMinutes;
					this.seconds = remainingSeconds > 9 ? remainingSeconds : '0' + remainingSeconds;
					this.guessingStart = false;
					this.guessingEnd = false;
					clearInterval(this.timer);
					this.timer = null;
					this.timer = setInterval(res => {
						this.getRemainingTimeToday(start_time,end_time);
					}, 1000)
					return;
				} else if (endOfDay - now > 0 && this.isCanguess){
					//已开始
					this.guessingStart = true;
					remainingMilliseconds = endOfDay - now;
					remainingSeconds = Math.floor(remainingMilliseconds / 1000);
					remainingMinutes = Math.floor(remainingSeconds / 60);
					remainingHours = Math.floor(remainingMinutes / 60);
					remainingSeconds %= 60;
					remainingMinutes %= 60;
					remainingHours %= 24;
					remainingHours<0?remainingHours=0:'';
					remainingMinutes<0?remainingMinutes=0:'';
					remainingSeconds<0?remainingSeconds=0:'';
					this.hours = remainingHours > 9 ? remainingHours : '0' + remainingHours;
					this.minutes = remainingMinutes > 9 ? remainingMinutes : '0' + remainingMinutes;
					this.seconds = remainingSeconds > 9 ? remainingSeconds : '0' + remainingSeconds;
					if (this.hours == '00' && this.minutes == '00' && this.seconds == '00') {
						this.guessingEnd = true;
						clearInterval(this.timer);
						this.timer = null;
						this.getActivityDetailQueryResult();
						this.getActivityDetailQueryRate();
						this.timer = setInterval(res => {
							this.getRemainingTimeToday(start_time,end_time);
						}, 1000)
					}
				} else {
					//已开始
					this.guessingStart = true;
					this.guessingEnd = true;
					remainingMilliseconds = new Date(now.getFullYear(),
														now.getMonth(), 
														now.getDate(), 
														'23', 
														'59', 
														'59', 
														999) - now;
					remainingSeconds = Math.floor(remainingMilliseconds / 1000);
					remainingMinutes = Math.floor(remainingSeconds / 60);
					remainingHours = Math.floor(remainingMinutes / 60);
					remainingSeconds %= 60;
					remainingMinutes %= 60;
					remainingHours %= 24;
					remainingHours<0?remainingHours=0:'';
					remainingMinutes<0?remainingMinutes=0:'';
					remainingSeconds<0?remainingSeconds=0:'';
					this.hours = remainingHours > 9 ? remainingHours : '0' + remainingHours;
					this.minutes = remainingMinutes > 9 ? remainingMinutes : '0' + remainingMinutes;
					this.seconds = remainingSeconds > 9 ? remainingSeconds : '0' + remainingSeconds;
					if (this.hours == '00' && this.minutes == '00' && this.seconds == '00') {
						clearInterval(this.timer);
						this.timer = null;
						this.getActivityDetailQueryResult();
						this.getActivityDetailQueryRate();
						this.timer = setInterval(res => {
							this.getRemainingTimeToday(start_time,end_time);
						}, 1000)
					}
				}
				
			},
			setTabbar() {
				uni.setTabBarItem({
					text: this.i18n4.l001,
					index: 0,
					selectedIconPath: "/static/images/tabbar/index3.png",
				})
				uni.setTabBarItem({
					text: this.i18n4.l002,
					index: 1,
					selectedIconPath: "/static/images/tabbar/market3.png",
				})
				uni.setTabBarItem({
					text: this.i18n4.l003,
					index: 2,
					selectedIconPath: "/static/images/tabbar/trade3.png",
				})
				uni.setTabBarItem({
					text: this.i18n4.l004,
					index: 3,
					selectedIconPath: "/static/images/tabbar/option3.png",
				})
				uni.setTabBarItem({
					text: this.i18n4.l005,
					index: 4,
					selectedIconPath: "/static/images/tabbar/property3.png",
				})
				if (this.model == 'light') {
					uni.setTabBarStyle({
						color: '#7F838D',
						selectedColor: '#5951BA',
						backgroundColor: '#FFFFFF',
						borderStyle: "#E6E8EF",
						success: res => {
							console.log(res, 'cs-setTabBarStyle')
						},
						fail: err => {
							console.log(err, 'cs2-setTabBarStyle')
						}
					})
				}else{
					uni.setTabBarStyle({
					  color: '#AAACB8',
					  selectedColor: '#F7F7F7',
					  backgroundColor: '#0E0F11',
					  borderStyle: '#0E0F11'
					})
				}
			},
			getDateByTime(date, time){
				return new Date(date.getFullYear(),
					date.getMonth(), 
					date.getDate(), 
					time.split(':')[0], 
					time.split(':')[1], 
					time.split(':')[2], 
					999);
			},
			getFormattedAmount(amount) {
				if(!amount){
					return "+0.00"
				}else{
					return `${amount >= 0 ? '+' : '-'}${Math.abs(amount)}`
				}
			}
		}
	}
</script>
<style scoped lang="scss">
	.vipIcon {
		width: 118rpx;
		height: 48rpx;
		background: rgba(255, 180, 31, 0.1);
		border-radius: 24rpx 0rpx 0rpx 0rpx;
		border: 2rpx solid rgba(255, 180, 31, 0.3);
		// position: fixed;
		// top: 294rpx;
		// right: 0;
		// z-index: 3000000001;
	}

	.kanz {
		padding: 8rpx 28rpx;
		font-size: 24rpx;
		color: #F7F7F7;
		border: 2rpx solid #D22540;
		border-radius: 36rpx;

		image {
			margin-left: 8rpx;
		}
	}

	.kanzLight {
		padding: 8rpx 28rpx;
		font-size: 24rpx;
		color: #D22540;
		background: rgba(210, 37, 64, 0.1);
		border: 2rpx solid #D22540;
		border-radius: 36rpx;
	}

	.kand {
		padding: 8rpx 28rpx;
		font-size: 24rpx;
		color: #F7F7F7;
		border: 2rpx solid #53D290;
		border-radius: 36rpx;

		image {
			margin-left: 8rpx;
		}
	}

	.kandLight {
		padding: 8rpx 28rpx;
		background: rgba(83, 210, 144, 0.1);
		border-radius: 36rpx;
		border: 2rpx solid #53D290;
		font-size: 24rpx;
		color: #53D290;
	}

	.btn {
		width: 178rpx;
		height: 64rpx;
		background: #16181C;
		border-radius: 36rpx;
		border: 2rpx solid #1F2128;
	}

	.btnLight {
		background: rgba(255, 255, 255, 0.1);
		border: 2rpx solid rgba(255, 255, 255, 0.1);
	}

	.mb14 {
		margin-bottom: 14rpx;
	}

	.dark-wrap2 {
		background: url(/static/images/index/1_dark.png);
		background-repeat: no-repeat;
		background-size: 750rpx 958rpx;
		padding-bottom: 30rpx;
	}

	/* 非夜间模式 */
	.light-wrap2 {
		background: url(/static/images/index/1_light.png);
		background-repeat: no-repeat;
		background-size: 750rpx 958rpx;
		padding-bottom: 30rpx;
	}

	// 顶部切换
	.topBar {
		width: 504rpx;
		min-height: 68rpx;
		border-radius: 34rpx;
		border: 2rpx solid #1F2128;
		font-size: 28rpx;

		.item {
			flex-shrink: 0;
			min-height: 64rpx;
			color: #7F838D;
			padding: 14rpx;
		}

		.item2 {
			flex-shrink: 0;
			min-height: 64rpx;
			color: #F7F7F7;
			background: #5951BA;
			border-radius: 34rpx;
			padding: 14rpx;
		}
	}

	.topBarLight {
		background: rgba(255, 255, 255, 0.3);
		border: none;

		.item {
			color: rgba(255, 255, 255, 0.8);
		}

		.item2 {
			color: #5951BA;
			background: #FFFFFF;
		}
	}

	// 公告
	.notice {
		margin: 0 auto;
		width: 690rpx;
		height: 64rpx;
		background: rgba(31, 33, 40, .4);
		border-radius: 54rpx;
		// margin-top: 26rpx;
		overflow: hidden;
	}

	.noticeLight {
		background: rgba(255, 255, 255, 0.3);
	}

	// 资产、收益
	.moneyType {
		font-size: 28rpx;
		color: #AAACB8;
	}

	.money {
		margin-top: 16rpx;
		font-weight: bold;
		font-size: 56rpx;
		color: #F7F7F7;
	}

	.moneyLight {
		color: #fff;
	}

	.money2 {
		margin-top: 16rpx;
		font-size: 24rpx;
		color: #AAACB8;

		.text {
			color: #D22540;
		}

		.text2 {
			color: #53D290;
		}
	}

	.money2Light {
		color: #fff;
	}

	// 报价
	.newPrice {
		margin: 0 auto;
		width: 690rpx;
		min-height: 106rpx;
		background: #16181C;
		border-radius: 124rpx 124rpx 124rpx 124rpx;
		border: 2rpx solid #1F2128;

		.item1 {
			flex-shrink: 0;
			min-height: 102rpx;

			.title {
				width: 140rpx;
				height: 44rpx;
				font-size: 28rpx;
				color: #AAACB8;
			}

			.desc {
				font-size: 22rpx;
				color: #7F838D;
			}
		}

		.item11 {
			flex-shrink: 0;
			min-height: 102rpx;
			background: #5951BA;
			border-radius: 10000rpx;

			.title {
				width: 140rpx;
				height: 44rpx;
				font-size: 28rpx;
				color: #F7F7F7;
			}

			.desc {
				font-size: 22rpx;
				color: #F7F7F7;
			}
		}

		.item2 {
			flex-shrink: 0;
			min-height: 102rpx;

			.desc {
				font-size: 22rpx;
				color: #7F838D;
			}
		}

		.item22 {
			flex-shrink: 0;
			min-height: 102rpx;
			background: #5951BA;
			border-radius: 10000rpx;

			.desc {
				font-size: 22rpx;
				color: #F7F7F7;
			}
		}
	}

	.newPriceLight {
		background: rgba(255, 255, 255, 0.4);
		border: none;
	}

	// 报价表
	.titleList {
		font-size: 24rpx;
		color: #AAACB8;
	}

	.titleListLight {
		color: #0E0F11;
	}

	.valueList {
		font-size: 24rpx;
		color: #F7F7F7;
	}

	.valueListLight {
		color: #7F838D;
	}

	.valueItem1 {
		color: #AAACB8;
	}

	.valueItem1Light {
		color: #7F838D;
	}

	.valueItem2 {
		font-size: 24rpx;
		color: #53D290;
	}

	.valueItem3 {
		font-size: 24rpx;
		color: #D22540;
	}

	// 活动
	.guess {
		background: #16181C;
		border-radius: 30rpx;
		border: 2rpx solid #1F2128;
		padding-bottom: 36rpx;

		.guessTitle {
			font-size: 32rpx;
			color: #82DA4C;
		}

		.guessTitle2 {
			font-size: 24rpx;
			color: #7F838D;

			.times {
				width: 36rpx;
				height: 32rpx;
				background: #1F2128;
				border-radius: 4rpx;
				font-size: 20rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 32rpx;
			}
		}
	}

	.guessLight {
		background: #FFFFFF;
		border: none;

		.guessTitle2 {
			color: #47474A;

			.times {
				background: #0E0F11;
			}
		}
	}

	// 最新资讯
	.news {
		background: #16181C;
		border-radius: 30rpx;
		border: 2rpx solid #1F2128;
		padding-bottom: 32rpx;

		.newsTitle {
			font-size: 32rpx;
			color: #F7F7F7;
		}

		.name {
			font-size: 28rpx;
			color: #AAACB8;
		}

		.time {
			font-size: 24rpx;
			color: #7F838D;
		}

		.seeMore {
			width: 630rpx;
			height: 50rpx;
			background: #1F2128;
			border-radius: 36rpx;
			font-size: 24rpx;
			color: #F7F7F7;
		}
	}

	.newsLight {
		background: #FFF;
		border: none;

		.newsTitle {
			color: #0E0F11;
		}

		.name {
			color: #0E0F11;
		}

		.seeMore {
			background: unset;
			border: 2rpx solid #F4F4F4;
			color: #7F838D;
		}
	}
</style>